<?php
/**
 * Created by : Sandi Rizky Kharisma (sandi.informatics08@gmail.com)
 * This Class Generated for CRUD purpose only
 */
class m_member extends CI_Model {

    function __construct() {
        parent::__construct();
    }

    public function get($where = null, $limit = null, $offset = null) {
        if($where != null) $this->db->where($where);
        if($limit != null && $offset != null) $this->db->limit($limit, $offset);
        return $this->db->get("member");
    }

    function get_all($limit, $uri) {

        $result = $this->db->get('member', $limit, $uri);
        if ($result->num_rows() > 0) {
            return $result->result_array();
        } else {
            return array();
        }
    }

    function get_one($id) {
        $this->db->where('ID_ANGGOTA', $id);
        $result = $this->db->get('member');
        if ($result->num_rows() == 1) {
            return $result;
        } else {
            return array();
        }
    }

    function insert() {
        $data = array(

                'ID_ANGGOTA' => $this->input->post('ID_ANGGOTA', TRUE),

                'PASSWORD' => md5($this->input->post('PASSWORD', TRUE)),

        );
        return $this->db->insert('member', $data);
    }

    function update($id) {
        $data = array(

                'ID_MEMBER_TYPE' => $this->input->post('ID_MEMBER_TYPE', TRUE),

                'USERNAME' => $this->input->post('USERNAME', TRUE),

                'PASSWORD' => $this->input->post('PASSWORD', TRUE),

                'JOIN_DATE' => $this->input->post('JOIN_DATE', TRUE),

        );
        $this->db->where('ID_MEMBER', $id);
        return $this->db->update('member', $data);
    }

    function delete($id) {
        $this->db->where('ID_MEMBER', $id);
        $this->db->delete('member');
    }

}
?>
